package ruru.server;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Test {
	private static final long SECOND = 1000;
	private static final long MINUTE = SECOND * 60;
	private static final long HOUR = MINUTE * 60;
	private static final long DAY = HOUR * 24;
	private static final long WEEK = DAY * 7;
	
	public static void main(String[] args) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("hh:mma EEE MM-dd-yyyy");
		Date past = sdf.parse("4:23pm Mon 09-10-2007");
		
		long diff = new Date().getTime() - past.getTime();
		String time = "uninitialized :P";
		
		if(diff < MINUTE) {
			time = (diff / SECOND) + ((diff/SECOND == 1)? " second": " seconds");
		} else if(diff < HOUR) {
			time = (diff / MINUTE) + ((diff/MINUTE == 1)? " minute" : " minutes");
		} else if (diff < DAY) {
			time = (diff / HOUR) + ((diff/HOUR == 1)? " hour" : " hours");
		} else if(diff < WEEK) {
			time = (diff / DAY) + ((diff/DAY == 1)? " day" : " days");
		} else {
			time = (diff / WEEK) + ((diff/WEEK == 1)? " week" : " weeks");	
		}
		
		System.out.println("updated " + time + " ago");
	}
}